package com.globallogic.training.vaskulg.binarytree;

public class BinaryTree<T extends Comparable<T>> {
	
	private Node<T> rootNode;
	private Node<T> currentNode;
	
	public BinaryTree(T rootNodeValue) {
		this.rootNode = new Node<T>(rootNodeValue);
		currentNode = this.rootNode;
	}

	public T getValue() {
		return currentNode.getValue();
	}
	
	public Node<T> moveLeft() {
		currentNode = currentNode.getLeftChild();
		
		return currentNode;
	}
	
	public Node<T> moveRight() {
		currentNode = currentNode.getRightChild();
		
		return currentNode;
	}
	
	public Node<T> moveToParent() {
		currentNode = currentNode.getParent();	
		
		return currentNode;
	}
	
	public void addLeftNode(T value) {
		currentNode.setLeftChild(new Node<T>(value));
	}
	
	public void addRightNode(T value) {
		currentNode.setRightChild(new Node<T>(value));
	}
	
	public void addValue(T value) {
		rootNode.addValue(value);
		
	}

	public int getHeight() {
		return rootNode.getHeight();
	}

	@Override
	public String toString() {
		return rootNode.toString();
	}	
}
